package com.frinder.wx.base.api.tuling.payload;

import lombok.Data;

/**
 * @ClassName TuLingRequest
 * @Description //TODO
 * @Author frinder
 * @Date 2018/12/6 14:56
 * @Version 1.0
 */
@Data
public class TuLingRequest {

    /**
     * reqType : 0
     * perception : {"inputText":{"text":"附近的酒店"},"inputImage":{"url":"imageUrl"},"selfInfo":{"location":{"city":"北京","province":"北京","street":"信息路"}}}
     * userInfo : {"apiKey":"","userId":""}
     */

    private int reqType;
    private Perception perception;
    private UserInfo userInfo;

    @Data
    public static class Perception {
        /**
         * inputText : {"text":"附近的酒店"}
         * inputImage : {"url":"imageUrl"}
         * selfInfo : {"location":{"city":"北京","province":"北京","street":"信息路"}}
         */

        private InputText inputText;
        private InputImage inputImage;
        private SelfInfo selfInfo;

        public Perception perception(InputText inputText, InputImage inputImage, SelfInfo selfInfo) {
            this.inputText = inputText;
            this.inputImage = inputImage;
            this.selfInfo = selfInfo;
            return this;
        }

        @Data
        public static class InputText {
            /**
             * text : 附近的酒店
             */

            private String text;

            public InputText text(String text) {
                this.text = text;
                return this;
            }
        }

        @Data
        public static class InputImage {
            /**
             * url : imageUrl
             */

            private String url;

            public InputImage image(String url) {
                this.url = url;
                return this;
            }
        }

        @Data
        public static class SelfInfo {
            /**
             * location : {"city":"北京","province":"北京","street":"信息路"}
             */

            private Location location;

            @Data
            public static class Location {
                /**
                 * city : 北京
                 * province : 北京
                 * street : 信息路
                 */

                private String city;
                private String province;
                private String street;

                public Location location(String city, String province, String street) {
                    this.city = city;
                    this.province = province;
                    this.street = street;
                    return this;
                }
            }

            public SelfInfo selfInfo(String city, String province, String street) {
                location = new Location().location(city, province, street);
                return this;
            }
        }
    }

    @Data
    public static class UserInfo {
        /**
         * apiKey :
         * userId :
         */

        private String apiKey;
        /**
         * 随便输入一个格式正确字符串即可
         */
        private String userId;

        public UserInfo userInfo(String apiKey, String userId) {
            this.apiKey = apiKey;
            this.userId = userId;
            return this;
        }
    }

    public TuLingRequest text(String text) {
        reqType = 0;
        perception = new Perception().perception(new Perception.InputText().text(text), null, null);
        userInfo = new UserInfo().userInfo("7d53fb36e3c3a85b1316a7a8b46c9bcb", "frinder6");
        return this;
    }
}
